import Vue from "vue";
import VueRouter from "vue-router";
import Loading from "../views/Loading.vue";
import Index2022 from "../views/Index2022.vue";
import Index2023 from "../views/Index2023.vue";
import Index2024 from "../views/Index2024.vue";
import Info2022 from "../views/Info2022";
import Button from "../views/Button";
import Wxapp from "../views/Wxapp";
import Main from "../views/Main.vue";
import Before from "../views/Before.vue";
import Cases from "../views/Cases.vue";
Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    name: "load",
    component: Loading,
  },
  {
    path: "/index2022",
    name: "index2022",
    component: Index2022,
  },
  {
    path: "/index2023",
    name: "index2023",
    component: Index2023,
  },
  {
    path: "/index2024",
    component: Index2024,
  },
  {
    path: "/info2022",
    component: Info2022,
  },
  {
    path: "/btn",
    component: Button,
  },
  {
    path: "/wxapp",
    component: Wxapp,
  },
  {
    path: "/main",
    component: Main,
  },
  {
    path: "/before",
    component: Before,
  },
  {
    path: "/cases",
    component: Cases,
  },
];

const router = new VueRouter({
  routes,
});

//全局路由守卫 应用场景：后台管理系统，必须登录才能跳转到主页面
// router.beforeEach((to, from, next) => {
//   console.log(to)
//   console.log(from)
//   const tokenStr = localStorage.getItem('token')
//   if (to.path === '/home' && !tokenStr) {
//     next('/login')
//   } else {
//     next()
//   }
// })
export default router;
